package com.yaya.spring.mybatis;

import com.yaya.spring.mybatis.dao.UserMapper;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * ImportBeanDefinitionRegistrarZyy
 *
 * @author zhougf
 * @date 2019/9/24
 */
public class ImportBeanDefinitionRegistrarZyy implements ImportBeanDefinitionRegistrar {
    public ImportBeanDefinitionRegistrarZyy() {
    }

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.
                genericBeanDefinition(MapperFactoryBeanZyy.class);
        beanDefinitionBuilder.addConstructorArgValue(UserMapper.class);
        AbstractBeanDefinition beanDefinition = beanDefinitionBuilder.getBeanDefinition();
        registry.registerBeanDefinition("xxx", beanDefinition);

    }
}
